import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';

// 应用程序优雅关闭
@Injectable()
export class PrismaService extends PrismaClient  implements OnModuleInit {
    constructor() {
    super({
      log: ['query']
    });
  }

  async onModuleInit() {
    await this.$connect();
  }



  // async enableShutdownHooks(app: INestApplication) {
  //   // this.$disconnect()
  //   // this.$on('beforeExit', async () => {
  //   //   await app.close();
  //   // });
  // }
}